// 位置获取 create by alex on 20200618
export const getLocation = () => {
	return new Promise((resolve, reject) => {
		uni.getLocation({
			type: 'wgs84',
			success: function(res) {
				resolve(res);
			},
			fail(res) {
				uni.redirectTo({
					url: '/pages/index/location/location_error/location_error'
				});
			}
		});
	}).catch((e) => {
		console.log(e);
	});

}

//跳转到位置获取错误页面
export const goToLocationError = () => {
	uni.redirectTo({
		url: '/pages/index/location/location_error/location_error'
	});
}


//保存用户经纬度数据
export const saveLocationData = (data) => {
	uni.setStorage({
		key: 'user_location',
		data: data,
		success: function() {
			console.log("saveLocationData success" );
		},
		fail() {

		}
	});
}

//获取用户经纬度数据
export const getLocationData = () => {
	var data = '';
	try {
	    data = uni.getStorageSync('user_location');
	} catch (e) {
	    // error
	}
	
	return data;
}

//获取当前时间戳
export const getCurTimestamp = () => {
	var timestamp = Date.parse(new Date());
	timestamp = timestamp / 1000;
	return timestamp;
}


//获取当前时间戳
export const uploadPageInfo = (data) => {
	this.$request({
		url: that.$api.myPrize.getAward,
		method: 'get',
		data: {
			activityid: that.activityId,
			pondLogsid:logid
		},
	}).then(info => {
		
		if(info.code == 203){
			uni.showToast({
				title: info.msg,
				icon: 'none'
			})
			return false;
		}else if(info.code == 200){
			that.pondList[index]['status'] = 1;
			uni.showToast({
				title: info.msg,
				icon: 'none'
			});
		}
	}).catch(error => {
		console.log(error)
	})
}